<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基本资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/public.css" media="all">
    <style>
        .layui-form-item .layui-input-company {
            width: auto;
            padding-right: 10px;
            line-height: 38px;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required">登录名</label>
                <div class="layui-input-block">
                    <input type="text" name="loginName" lay-verify="required" lay-reqtext="登录名不能为空" placeholder="请输入登录名"
                           value="admin" class="layui-input">
                    <tip>填写自己登录名的名称。</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="required" lay-reqtext="密码不能为空"
                           placeholder="请输入密码" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">真实姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="realName" lay-verify="required" lay-reqtext="真实姓名不能为空"
                           placeholder="请输入真实姓名" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" lay-verify="email" autocomplete="off" placeholder="请输入邮箱" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                    <button class="layui-btn layui-btn-normal" id="returnIndex">返回首页</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>

<script>
    layui.use(['form', 'miniTab', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab;
        var $ = layui.$ //重点处
        $("#returnIndex").click(function () {
            window.location.href = "/"
        })
        //监听提交
        form.on('submit(saveBtn)', function (data) {

             data = data.field;
            if (data.loginName == '') {
                layer.msg('登录名不能为空');
                return false;
            }
            if (data.password == '') {
                layer.msg('密码不能为空');
                return false;
            }
            if (data.realName == '') {
                layer.msg('真实姓名不能为空');
                return false;
            }
            if (data.email == '') {
                layer.msg('个人邮箱不能为空');
                return false;
            }
            $.post("/registerUser",
                {
                    loginName: data.loginName,
                    realName: data.realName,
                    email: data.email,
                    password: data.password
                },
                function (data, status) {
                    layer.msg(data.msg, function () {
                        if (data.code == 200) {
                            window.location.href = "/";
                        }
                    });
                });

            return false;
        });


    });
</script>
</body>
</html>